#pragma once

#include <math.h>

#include "Point.h";

template<typename T2> class Vector
{
	public:
		Vector (const Point<T2>& i_p1, const Point<T2>& i_p2):m_x(i_p2.m_x-i_p1.m_x),
			m_y(i_p2.m_y-i_p1.m_y), m_z(i_p2.m_z-i_p1.m_z){};
		Vector():m_x(0),m_y(0),m_z(0){};
		Vector(T2 i_x, T2 i_y, T2 i_z):m_x(i_x), m_y(i_y), m_z(i_z){};
		Vector& operator = (const Vector& i_other);
		Vector operator ^ (const Vector& i_other);
		Vector operator - ();
		T2 operator * (const Vector& i_other);
		double length();
		
		T2 m_x;
		T2 m_y;
		T2 m_z;
		
};






template<typename T2> Vector<T2>& Vector<T2>:: operator =(const Vector<T2>& i_v)
{
	if(this==&i_v)
		return *this;
	m_x=i_v.m_x;
	m_y=i_v.m_y;
	m_z=i_v.m_z;
	return *this;
};

template<typename T2> Vector<T2> Vector<T2>:: operator ^(const Vector<T2>& i_v)
{
	Vector<T2> res;
	res.m_x= m_y * i_v.m_z - m_z * i_v.m_y;
	res.m_y= m_z * i_v.m_x - m_x * i_v.m_z;
	res.m_z= m_x * i_v.m_y - m_y * i_v.m_x;
	return res;
};


template<typename T2> Vector<T2> Vector<T2>:: operator -()
{
	Vector<T2> res;
	res.m_x= -m_x;
	res.m_y= -m_y;
	res.m_z= -m_z;
	return res;
};


template<typename T2> T2 Vector<T2>:: operator *(const Vector<T2>& i_v) 
{
	return m_x*i_v.m_x + m_y*i_v.m_y + m_z*i_v.m_z;
};

template<typename T2> double Vector<T2>:: length ()
{
	return std::sqrt(double(m_x*m_x + m_y*m_y + m_z*m_z));	
};